package com.xinziruo.richclient.engine.impl;

import org.apache.commons.lang.StringUtils;

import com.xinziruo.richclient.engine.PayloadSource;

/**
 * 
 * @author loudyn
 * 
 */
public class StringListPayloadSource implements PayloadSource {

	private String[] payloadStrings;
	private int current = -1;

	public StringListPayloadSource(String stringList) {
		stringList = null == stringList ? "" : stringList;
		payloadStrings = StringUtils.split(stringList, ';');
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.youboy.crawl.domain.intruder.Payload#hasNext()
	 */
	@Override
	public boolean hasNext() {
		current++;
		return current < payloadStrings.length;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.youboy.crawl.domain.intruder.Payload#reset()
	 */
	@Override
	public void reset() {
		current = -1;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.youboy.crawl.domain.intruder.Payload#getPayload()
	 */
	@Override
	public String getPayload() {
		return payloadStrings[current];
	}

}
